package com.hzhr.iot.device.convertor;

import com.hzhr.iot.device.convertor.custom.*;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.core.util.HzhrJsonUtil;
import java.util.Map;
import com.hzhr.iot.device.model.prodFactory.ProdFactoryModel;
import com.hzhr.iot.device.model.prodFactory.ProdFactoryPostModel;
import com.hzhr.iot.device.entity.ProdFactoryEntity;
import com.hzhr.iot.device.entity.ext.ProdFactoryEntityExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.hzhr.iot.device.model.prodFactory.ProdFactoryModel;
import com.hzhr.iot.device.model.prodFactory.ProdFactoryGetModel;
import com.hzhr.iot.device.model.prodFactory.ProdFactoryPostModel;
import com.hzhr.iot.device.queryModel.custom.ProdFactoryCustomQueryModel;

@Component
public class ProdFactoryConvertor {
    @Autowired
    AlarmDataCustomConvertor alarmDataCustomConvertor;
    @Autowired
    CollectDataCustomConvertor collectDataCustomConvertor;
    @Autowired
    CollectDeviceCustomConvertor collectDeviceCustomConvertor;
    @Autowired
    CollectDeviceTypeCustomConvertor collectDeviceTypeCustomConvertor;
    @Autowired
    DeviceInfoCardCustomConvertor deviceInfoCardCustomConvertor;
    @Autowired
    DeviceMaintenanceCardCustomConvertor deviceMaintenanceCardCustomConvertor;
    @Autowired
    DeviceMaintenanceCardItemCustomConvertor deviceMaintenanceCardItemCustomConvertor;
    @Autowired
    ImplFactoryCustomConvertor implFactoryCustomConvertor;
    @Autowired
    ImplIotDeviceTypeCustomConvertor implIotDeviceTypeCustomConvertor;
    @Autowired
    ImplRecordCustomConvertor implRecordCustomConvertor;
    @Autowired
    IotDeviceCustomConvertor iotDeviceCustomConvertor;
    @Autowired
    IotDeviceTypeCustomConvertor iotDeviceTypeCustomConvertor;
    @Autowired
    OptionsCustomConvertor optionsCustomConvertor;
    @Autowired
    RegulatorCollectDataCustomConvertor regulatorCollectDataCustomConvertor;
    @Autowired
    UserCompanyCustomConvertor userCompanyCustomConvertor;

    public ProdFactoryEntity prodFactoryModel2entity(ProdFactoryModel in) {
        //未转换字段: createUserId iotCompanyId createTime updateUserId isValid outId updateTime state 
        if (in == null) return null;
        ProdFactoryEntity result = new ProdFactoryEntity();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        return result;
    }
    public ProdFactoryEntity prodFactoryModel2entity(ProdFactoryModel in, ProdFactoryEntity ori) {
        //未转换字段: createUserId iotCompanyId createTime updateUserId isValid outId updateTime state 
        if (in == null) return null;
        ProdFactoryEntity result = ori;

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        return result;
    }
    public List<ProdFactoryEntity> prodFactoryModelList2entityList(List<ProdFactoryModel> in) {
        if (in == null) return null;
        List<ProdFactoryEntity> result = new ArrayList<>();
        for (ProdFactoryModel item : in) {
            result.add(prodFactoryModel2entity(item));
        }
        return result;
    }
    public ProdFactoryModel entity2prodFactoryModel(ProdFactoryEntity in) {
        //未转换字段: 
        if (in == null) return null;
        ProdFactoryModel result = new ProdFactoryModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        return result;
    }
    public List<ProdFactoryModel> entityList2prodFactoryModelList(List<ProdFactoryEntity> in) {
        if (in == null) return null;
        List<ProdFactoryModel> result = new ArrayList<>();
        for (ProdFactoryEntity item : in) {
            result.add(entity2prodFactoryModel(item));
        }
        return result;
    }
    public ProdFactoryModel ext2prodFactoryModel(ProdFactoryEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        ProdFactoryModel result = new ProdFactoryModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        return result;
    }
    public List<ProdFactoryModel> extList2prodFactoryModelList(List<ProdFactoryEntityExt> in) {
        if (in == null) return null;
        List<ProdFactoryModel> result = new ArrayList<>();
        for (ProdFactoryEntityExt item : in) {
            result.add(ext2prodFactoryModel(item));
        }
        return result;
    }
    public ProdFactoryGetModel extList2prodFactoryGetModel(List<ProdFactoryEntityExt> extList, Integer total, Integer changeCount, Map<String, Object> query) {
        List<ProdFactoryModel> modelList = extList2prodFactoryModelList(extList);
        if (modelList == null) {
            ProdFactoryGetModel result = new ProdFactoryGetModel();
            result.setTotal(total);
            result.setChangeCount(changeCount);
            return result;
        }

         String _show = HzhrTypeUtil.object2string(query.get("_show"));
         Boolean _show_info = query.get("_show_info") != null ? Boolean.parseBoolean(query.get("_show_info").toString()) : false;

        if (!_show_info) {
            for (ProdFactoryModel model : modelList) {
                model.setDes(null);
                model.setCompanyId(null);
            }
        }

        ProdFactoryGetModel result = new ProdFactoryGetModel();
        if ("one".equals(_show)) {
            if (modelList.size() > 0) {
                result.setModel(modelList.get(0));
            }
         }
        if ("list".equals(_show)) {
            result.setModelList(modelList);
        }
        result.setTotal(total);
        result.setChangeCount(changeCount);
        return result;
    }
    public ProdFactoryGetModel entity2prodFactoryGetModel(ProdFactoryEntity entity, Integer total, Integer changeCount, Map<String, Object> query) {
        List<ProdFactoryEntityExt> extList = new ArrayList<>();
        if (entity == null) return extList2prodFactoryGetModel(extList, total, changeCount, query);
        extList.add(HzhrJsonUtil.convertObjectType(entity, ProdFactoryEntityExt.class));
        return extList2prodFactoryGetModel(extList, total, changeCount, query);
     }
    public ProdFactoryEntity prodFactoryPostModel2entity(ProdFactoryPostModel in) {
        //未转换字段: createUserId iotCompanyId createTime updateUserId isValid outId updateTime id state 
        if (in == null) return null;
        ProdFactoryEntity result = new ProdFactoryEntity();

        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        return result;
    }
    public ProdFactoryEntity prodFactoryPostModel2entity(ProdFactoryPostModel in, ProdFactoryEntity ori) {
        //未转换字段: createUserId iotCompanyId createTime updateUserId isValid outId updateTime id state 
        if (in == null) return null;
        ProdFactoryEntity result = ori;

        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        return result;
    }
    public List<ProdFactoryEntity> prodFactoryPostModelList2entityList(List<ProdFactoryPostModel> in) {
        if (in == null) return null;
        List<ProdFactoryEntity> result = new ArrayList<>();
        for (ProdFactoryPostModel item : in) {
            result.add(prodFactoryPostModel2entity(item));
        }
        return result;
    }
    public ProdFactoryPostModel entity2prodFactoryPostModel(ProdFactoryEntity in) {
        //未转换字段: 
        if (in == null) return null;
        ProdFactoryPostModel result = new ProdFactoryPostModel();

        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        return result;
    }
    public List<ProdFactoryPostModel> entityList2prodFactoryPostModelList(List<ProdFactoryEntity> in) {
        if (in == null) return null;
        List<ProdFactoryPostModel> result = new ArrayList<>();
        for (ProdFactoryEntity item : in) {
            result.add(entity2prodFactoryPostModel(item));
        }
        return result;
    }
    public ProdFactoryPostModel ext2prodFactoryPostModel(ProdFactoryEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        ProdFactoryPostModel result = new ProdFactoryPostModel();

        result.setDes(HzhrTypeUtil.string2string(in.getDes()));
        result.setCompanyId(HzhrTypeUtil.integer2integer(in.getCompanyId()));
        return result;
    }
    public List<ProdFactoryPostModel> extList2prodFactoryPostModelList(List<ProdFactoryEntityExt> in) {
        if (in == null) return null;
        List<ProdFactoryPostModel> result = new ArrayList<>();
        for (ProdFactoryEntityExt item : in) {
            result.add(ext2prodFactoryPostModel(item));
        }
        return result;
    }
    public ProdFactoryCustomQueryModel prodFactoryService_query2queryModel(Map<String, Object> query) {
        ProdFactoryCustomQueryModel queryModel = new ProdFactoryCustomQueryModel();

        Integer _equal_id = HzhrTypeUtil.object2integer(query.get("_equal_id"));
        if (_equal_id != null) {
            queryModel.setEqual_id(_equal_id);
         }

        Integer _equal_companyId = HzhrTypeUtil.object2integer(query.get("_equal_companyId"));
        if (_equal_companyId != null) {
            queryModel.setEqual_companyId(_equal_companyId);
         }

        Boolean _show_info = HzhrTypeUtil.object2boolean(query.get("_show_info"));
        if (_show_info != null && _show_info) {
            queryModel.setShow(true);
            queryModel.setShow(true);
        }

        Integer page = HzhrTypeUtil.object2integer(query.get("_page"));
        Integer count = HzhrTypeUtil.object2integer(query.get("_count"));
        queryModel.setPage(page, count);

        return queryModel;
    }

}

